#include "StdAfx.h"
#include "AboutDialog.h"

/////////////////////////////////////////////////////////////////////////////
// CAboutDialog dialog
CAboutDialog *CAboutDialog::s_pAboutWindow = 0;

CAboutDialog::CAboutDialog(const Version &v, CWnd* pParent /*=NULL*/)
: CDialog(CAboutDialog::IDD, pParent)
{
	m_version = v;
}

CAboutDialog::~CAboutDialog()
{
	s_pAboutWindow = 0;
}

void CAboutDialog::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_ABOUT_VERSION, m_TransparentVersion);
	DDX_Control(pDX, IDC_ABOUT_COPYRIGHT , m_TransparentCopyright);
	DDX_Control(pDX, IDC_ABOUT_ALLRIGHTRESERVED, m_TransparentAllRightReserved);
	DDX_Control(pDX, IDC_ABOUT_TRADEMARKS, m_TransparentTrademarks);
	DDX_Control(pDX, IDC_ABOUT_DEVELOPEDBY  , m_TransparentDevelopedBy);
	//{{AFX_DATA_MAP(CStartupLogoDialog)
	// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CAboutDialog, CDialog)
	//{{AFX_MSG_MAP(CAboutDialog)
	//}}AFX_MSG_MAP
	ON_WM_LBUTTONUP()
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
BOOL CAboutDialog::OnInitDialog() 
{
	s_pAboutWindow = this;

	m_TransparentCopyright.SetTextColor(RGB(255,255,255));
	m_TransparentVersion.SetTextColor(RGB(255,255,255));
	m_TransparentAllRightReserved.SetTextColor(RGB(255,255,255));
	m_TransparentTrademarks.SetTextColor(RGB(255,255,255));
	m_TransparentDevelopedBy.SetTextColor(RGB(255,255,255));
	SetVersion(m_version);

	if (CStatic* pPictureCtrl = (CStatic*)GetDlgItem(IDC_STATIC))
	{
		LPCTSTR bitmapResource = MAKEINTRESOURCE(gSettings.gui.bDarkSkin ? IDB_ABOUT_DARK : IDB_ABOUT_LIGHT);
		HBITMAP bitmap = ::LoadBitmap(AfxGetInstanceHandle(), bitmapResource);
		pPictureCtrl->SetBitmap(bitmap);
	}

	return CDialog::OnInitDialog();
}

void CAboutDialog::OnLButtonUp(UINT nFlags, CPoint point) 
{
	s_pAboutWindow->EndDialog(IDOK);

}

void CAboutDialog::SetVersion( const Version &v )
{
	if (!m_hWnd)
		return;

	char pVersionText[256];
	_snprintf(pVersionText, 256, "Version %d.%d.%d - Build %d", v[3], v[2], v[1], v[0]);







	_snprintf(pVersionText, 256, "Version %d.%d.%d - Build %d", v[3], v[2], v[1], v[0]);

	SetDlgItemText(IDC_ABOUT_TRADEMARKS, CString(pVersionText));
}
